home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 19 / Amiga Plus Leser CD 19.iso / Tools / Freeware / Swf_Player / Lib / sound.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-11-17  |  2.4 KB  |  90 lines

  1. /////////////////////////////////////////////////////////////
  2. // Flash Plugin and Player
  3. // Copyright (C) 1998 Olivier Debon
  4. // 
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU General Public License
  7. // as published by the Free Software Foundation; either version 2
  8. // of the License, or (at your option) any later version.
  9. // 
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14. // 
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18. // 
  19. ///////////////////////////////////////////////////////////////
  20. #ifndef _SOUND_H_
  21. #define _SOUND_H_
  22.  
  23. #define GET_SOUND_RATE_CODE(f) (((f)&0x0c)>>2)
  24.  
  25. class Sound : public Character {
  26.     long         soundRate;    // In hz
  27.     long         stereo;    // True if stereo sound
  28.     long         sampleSize;    // 1 or 2 bytes
  29.  
  30.     char        *samples;        // Array of samples
  31.     long         nbSamples;
  32.  
  33. public:
  34.     Sound(long id);
  35.     ~Sound();
  36.     void         setSoundFlags(long f);
  37.     char        *setNbSamples(long n);
  38.  
  39.     long         getRate();
  40.     long         getChannel();
  41.     long         getNbSamples();
  42.     long         getSampleSize();
  43.     char        *getSamples();
  44. };
  45.  
  46. struct SoundList {
  47.     long     rate;
  48.     long     stereo;
  49.     long     sampleSize;
  50.     long     nbSamples;
  51.     long     remaining;
  52.     char    *current;
  53.  
  54.     SoundList *next;
  55. };
  56.  
  57. class SoundMixer {
  58.  
  59.     SoundList    *list;
  60.  
  61. #ifdef AMIGA
  62.     char *         buffer1;
  63.     char *         buffer2;
  64. #endif
  65.  
  66. // Class variables
  67. static  long         dsp;        // Descriptor for /dev/dsp
  68. static  char *         buffer;    // DMA buffer
  69. static    long         blockSize;
  70. static    long         nbInst;    // Number of instances
  71.  
  72.     // Sound Device Capabilities
  73. static    long         soundRate;    // In hz
  74. static    long         stereo;    // True if stereo sound
  75. static    long         sampleSize;    // 1 or 2 bytes
  76.  
  77. public:
  78.     SoundMixer(char*);
  79.     SoundMixer(int flags);        // Amiga specific flags (was Linux device i.e. "/dev/dsp" ) */
  80.     ~SoundMixer();
  81.  
  82.     void         startSound(Sound *sound);    // Register a sound to be played
  83.     void         stopSounds();        // Stop every current sounds in the instance
  84.  
  85.     long         playSounds();        // Actually play sounds of all instances
  86.     long         fillSoundBuffer(SoundList *, char *buffer, long bufferSize); // Fill sound buffer
  87. };
  88.  
  89. #endif /* _SOUND_H_ */
  90.